import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

const store = new Vuex.Store({
	state:{//设置属性 用来存储数据
		user: JSON.parse(sessionStorage.getItem('user')),
		carousel_picture: '',
		files: '',
		uploading:{status:false,percentage:0},
		article_content:'',
		type:'',
		cover:'',
		certificate:''
		},
	getters:{//对应方法 用来获取属性的状态
			getUser:state => state.user,
			getCarouselPicture:state => state.carousel_picture,
			getFiles:state => state.files,
			getUploading:state => state.uploading,
			getArticleContent:state => state.article_content,
			getType:state => state.type,
			getCover:state => state.cover,
			getCertificate:state => state.certificate,
		},
	mutations:{//更改属性的状态
		setUser(state,data){
			sessionStorage.setItem('user',JSON.stringify(data))
			state.user = data
		},
		setCarouselPicture(state, data){
			state.carousel_picture = data
		},
		setArticleContent(state, data){
			state.article_content = data
		},
		setFiles(state,data){
			state.files = data
		},
		setUploading(state,data){
			state.uploading = data
		},
		setType(state,data){
			state.type = data
		},
		setCover(state,data){
			state.cover = data
		},
		setCertificate(state,data){
			state.certificate = data
		},
		},
	actions:{//应用 mutation
			
		}
})

export default store
